package Demo;

import java.util.concurrent.CountDownLatch;

public class Demo25 {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);
        for (int i = 0;i < 5;i++){
            Thread t = new Thread(() ->{
                System.out.println(Thread.currentThread().getName()+" 执行任务");
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                countDownLatch.countDown();
            });
            t.start();
        }

        countDownLatch.await();
    }
}
